#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
#define int long long
signed main() 
{
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;++i) 
	{
		cin>>a[i];
	}
	int sum_all = 0;
	for(int i=0;i<n;++i) 
	{
		for(int j=i+1;j<n;++j) 
		{
			sum_all+=abs(a[i]-a[j]);
		}
	}
	int p=(sum_all%MOD)*2%MOD;
	int q=n;
	int tmp=1;
	int base=q;
	int ex=MOD-2;
	while (ex>0) 
	{
		if(ex%2==1) 
		{
			tmp=(tmp*base)%MOD;
		}
		base=(base*base)%MOD;
		ex/=2;
	}
	int ans=(p*tmp)%MOD;
	cout<<ans<<endl;
	return 0;
}
